package yk.com.AllMenu;

import yk.com.Student;
import yk.com.StudentManager;
import java.util.Scanner;

public class ModifyStudent {
    public static void execute(Scanner scanner) {
        System.out.print("请输入要修改学生的学号: ");
        String oldId = scanner.nextLine();

        if (!StudentManager.isStudentIdExists(oldId)) {
            System.out.println("未找到该学号的学生！");
            return;
        }

        // 输入新的学生信息
        System.out.print("请输入新的学号: ");
        String newId = scanner.nextLine();
        System.out.print("请输入新的姓名: ");
        String newName = scanner.nextLine();
        System.out.print("请输入新的年龄: ");
        int newAge = scanner.nextInt();
        scanner.nextLine(); // 清除输入缓冲区
        System.out.print("请输入新的住址: ");
        String newAddress = scanner.nextLine();

        // 创建新的学生对象
        Student newStudent = new Student(newId, newName, newAge, newAddress);
        StudentManager.modifyStudent(oldId, newStudent);
    }
}